package com.aiwiown.snackmq.common.exception;

import lombok.Getter;

/**
 * Custom exception for serialization and deserialization errors.
 * It now includes an error code for more specific error handling.
 */
@Getter
public class SerializationException extends RuntimeException {

    private static final long serialVersionUID = -156897122718769030L;
    private final int code;

    public SerializationException(String message) {
        super(message);
        this.code = -1; // Default code for legacy calls
    }

    public SerializationException(String message, Throwable cause) {
        super(message, cause);
        this.code = -1; // Default code for legacy calls
    }

    /**
     * --- The missing constructor that caused the compilation errors ---
     * @param code A specific error code.
     * @param message A descriptive message.
     * @param cause The underlying cause of the exception.
     */
    public SerializationException(int code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }
}